const express = require('express');
const router = express.Router();
const connection = require("../util/db")
const ResultJson = require("../util/json")
const {formatArray} = require("../util/jsonFormat")

/* GET home page. */
router.get('/', function (req, res, next) {
    res.render('index', {title: '周六不放假'});
});

router.get("/list", function (req, res) {
    const {userId} = req.query;
    connection.query("select * from image where user_id = ?", userId, function (e, r) {
        if (e) {
            throw e;
        }
        res.json(ResultJson.data(formatArray(r)));
    })
})

module.exports = router;
